﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using YemekteyizLib.Bs;
using YemekteyizLib;

public partial class _Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            
            HttpCookie ilKukisi = Request.Cookies["yemekteyizIl"];
            if (ilKukisi != null)
            {
                string ilID = ilKukisi.Values["ilID"];
                Session["ilID"] = ilID;
                Response.Redirect("main.aspx");
            }
            else
            {
                DropDownList1.DataTextField = "Adi";
                DropDownList1.DataValueField = "ID";
                List<Il> iller = IlProvider.GetAll();
                DropDownList1.DataSource = iller;
                DropDownList1.DataBind();
            }




        }

    }
    protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
    {
        KukiOlusturYonlendir(DropDownList1.SelectedValue);
    }


    private void KukiOlusturYonlendir(string value)
    {
        Session["ilID"] = DropDownList1.SelectedValue;
        HttpCookie kuki = new HttpCookie("yemekteyizIl");
        kuki.Values.Add("ilID", value);
        kuki.Expires = DateTime.Now.AddMonths(1);
        Response.Cookies.Add(kuki);

        Response.Redirect("main.aspx");
    }
}
